#include "LPC11xx.h"
#include "utilfun.h"
#include "gpio.h"
#include "timer16.h"
#include "api_stiio.h"

/***************************************************************
 * Macro definitions                                           *
 ***************************************************************/

/***************************************************************
 * Globol variables                                            *
 ***************************************************************/

/***************************************************************
 * Functions                                                   *
 ***************************************************************/
void myDelay (uint32_t ulTime)
{
    uint32_t i;

    i = 0;
    while (ulTime--) {
        for (i = 0; i < 5000; i++);
    }
}

/***************************************************************
 * MAIN                                                        *
 ***************************************************************/
int main (void)
{
    uint32_t period = 25 * (SystemAHBFrequency / 1000000);
    SystemInit();             /* MUST BE INCLUDED! */

    GPIOInit();
    // LED
    GPIOSetDir(2, 7, GPIO_DIR_OUTPUT);

	utilInit();

	StiInit();
	MyStdout=LCD;
    
    Timer16InitPWM(0, period, MATCH0, 0);
    Timer16SetMatchPWM(0, 0, period/2);
    Timer16Enable(0);

	printf("Hello,STIer!\n");

    while (1) {
        Timer16Enable(0);
        utilSleepMs(500);
        Timer16Disable(0);
        utilSleepMs(500);
    }
}

/***************************************************************
 * END OF FILE                                                 *
 ***************************************************************/
